<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = '合同列表';
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = ['label' => '合同管理', 'url' => ['/admin/contract/list']];
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = $this->title;
$title=Yii::$app->request->get('title');
$number = Yii::$app->request->get('number');
$css=<<<css
.form-group{float: left;margin:0 10px 10px 0;}
.form-group select{height: 30px;}
.post-search{float: left;margin:10px 0px;}
.common-ui{height: 40px;line-height: 40px;background:#169dd9;width: 100%;color:#fff;font-size: 14px;text-indent: 12px;display: block;float: left;margin-bottom: 10px;font-weight:normal;}
css;
$this->registerCss($css);
?>
    <!-- main container -->
        
        <div class="container-fluid">
            <div id="pad-wrapper" class="users-list">
                <div class="row-fluid header">
                    <h3>合同列表</h3>
                    <div class="span10 pull-right">
                        <a href="<?php echo yii\helpers\Url::to(['contract/add']) ?>" class="btn-flat success pull-right">
                            <span>&#43;</span>
                            添加新合同
                        </a>
                    </div>
                </div>
                <h3 class="common-ui" >查询</h3>
                <div class="comment-search" style="display: block;">
                    <div class="post-search">
                        <?php
                        $action=Url::to(['contract/list']);
                        $form = ActiveForm::begin([
                            'action' => $action,
                            'method' => 'get',
                            'options'=>["class"=>"form-inline"],
                        ]);
                        ?>
                        <div class="form-group">
                            <?php echo Html::label('合同名称:　', null). Html::textInput('title',$title,['placeholder' => '请输入合同名称']); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::label('合同编号:　', null). Html::textInput('number',$number,['placeholder' => '请输入合同编号']); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::submitButton('查询', ['class' => 'btn btn-primary']); ?>
                            <?php echo Html::a('重置',Url::to(['contract/list']), ['class' => 'btn btn-default']);?>
                        </div>
                        <?php ActiveForm::end(); ?>
                    </div>
                </div>

                <h3 class="common-ui" ><?php echo $this->title;?></h3>

                <!-- Users table -->
                <div class="row-fluid table">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th class="span3 sortable">
                                <span class="line"></span>ID
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>合同名称
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>合同编号
                            </th>
                            <?php if(!$bool):?>
                            <th class="span3 sortable">
                                <span class="line"></span>合同价格
                            </th>
                            <?php endif;?>
                            <th class="span3 sortable align-right">
                                <span class="line"></span>操作
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <!-- row -->
                        <?php foreach($data as $v): ?>
                            <tr class="first">
                                <td>
                                    <?php echo $v['id'] ?>
                                </td>
                                <td>
                                    <?php echo $v['title'] ?>
                                </td>
                                <td>
                                    <?php echo $v['number'] ?>
                                </td>
                                <?php if(!$bool):?>
                                <td>
                                    <?php echo $v['price'] ?>
                                </td>
                                <?php endif;?>
                                <td class="align-right">
                                    <a href="<?php echo yii\helpers\Url::to(['contract/mod', 'id' => $v['id']]); ?>">编辑</a>
                                    <a href="<?php echo yii\helpers\Url::to(['contract/del', 'id' => $v['id']]); ?>">删除</a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                    <?php
                    if (Yii::$app->session->hasFlash('info')) {
                        echo Yii::$app->session->getFlash('info');
                    }
                    ?>
                </div>
                <div class="pagination pull-right">
                    <?php echo yii\widgets\LinkPager::widget([
                        'pagination' => $pager,
                        'prevPageLabel' => '&#8249;',
                        'nextPageLabel' => '&#8250;',
                        ]); ?>
                </div>
                <div class="pagination pull-right">
                    <span>共<?php echo $total;?>条</span>
                    <div class="pagination ui-select" style="margin-right: 10px;">
                        <select name="per-page">
                            <option value="10">10条/页</option>
                            <option value="20">20条/页</option>
                            <option value="50">50条/页</option>
                            <option value="100">100条/页</option>
                            <option value="200">200条/页</option>
                            <option value="300">300条/页</option>
                            <option value="500">500条/页</option>
                        </select>
                    </div>
                </div>
                <!-- end users table -->
            </div>
        </div>
<?php
$jspage=<<<JS
$(":input[name=per-page]").val($pagesize);
$(":input[name=per-page]").change(function() {
    var size=$(':input[name=per-page]').find('option:selected').val();
    window.location.href='$pageurl'+size;
});
JS;
$this->registerJs($jspage);
?>
